package ddd7;

import java.util.*;

public class SortCharacter {
    public static void main(String[] args) {
        System.out.println("Enter the string,Enter the end to end");
        List<String> str = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        while(true) {
            String s = sc.nextLine();
            if(s.equals("end")) {
                break;
            }
            String[] strings = s.split(" ");
            str.addAll(Arrays.asList(strings));
        }
        str.sort(Comparator.comparingInt(String::length));
        for(String s : str) {
            System.out.println(s);
        }
    }
}
